<template>
    <div>
        <van-nav-bar title="详情页" left-text="返回" left-arrow @click-left="() => { { $router.back('/') } }" />
        <div v-html="detdata.goods_introduce"></div>
        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" />
            <van-action-bar-icon icon="shop-o" text="店铺" />
            <van-action-bar-button color="#be99ff" type="warning" text="加入购物车" @click="goCart" />
            <van-action-bar-button color="#7232dd" type="danger" text="立即购买" />
        </van-action-bar>

    </div>
</template>

<script setup>
import { ref } from 'vue'
import { detailApi } from '@/api/api';
import { useRoute } from 'vue-router';
const route = useRoute()
console.log('详情数据', route.params.goods_id);
let detdata = ref([])
detailApi(route.params.goods_id).then(res => {
    console.log('详情内容', res);
    detdata.value = res.data.message
})

import { useRouter } from 'vue-router';
const router=useRouter()
import { useCounterStore } from '@/stores/cart.js'
// 可以在组件中的任意位置访问 `store` 变量 ✨
const store = useCounterStore()

const goCart=()=>{
    store.addcart(detdata,route.params.goods_id)
    router.push('/home/cal')
}

</script>

<style lang="scss" scoped></style>